package com.qf.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.dao.RechargeOrderDao;
import com.qf.entity.RechargeOrder;
import com.qf.service.RechargeOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**/
@Service
public class RechargeOrderServiceImpl implements RechargeOrderService {
    @Autowired
    private RechargeOrderDao rechargeOrderDao;

    //新增订单
    @Override
    public int insertOrder(RechargeOrder rechargeOrder) {
        return rechargeOrderDao.insert(rechargeOrder);
    }

    //根据id查订单列表
    @Override
    public List<RechargeOrder> queryRechargeOrderByUid(Integer uid) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("u_id", uid);
        queryWrapper.orderByDesc("create_time");//根据创建时间降序
        return rechargeOrderDao.selectList(queryWrapper);
    }

    //根据订单号修改订单状态
    @Override
    public int updateOrderStatus(String orderId, Integer status) {
        RechargeOrder rechargeOrder = rechargeOrderDao.selectById(orderId);
        rechargeOrder.setStatus(status);
        return rechargeOrderDao.updateById(rechargeOrder);
    }
    //根据id查询订单详细信息

    @Override
    public RechargeOrder getByOrderId(String orderId) {
        return rechargeOrderDao.selectById(orderId);
    }

    //支付宝支付
    @Override
    public String alipayOrder(String orderId) {
        return null;
    }
}
